package bit.mybatisdemo.demos.service;

import bit.mybatisdemo.demos.mapper.UserInfoMapper;
import bit.mybatisdemo.demos.model.UserInfo;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UserService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    public List<UserInfo>getAllUser(){
        return userInfoMapper.selectAll();
    }


    public UserInfo getUserById(int id){
        return userInfoMapper.selectAllById(id);
    }

    public UserInfo queryUser(String username, String password) {
        List<UserInfo>userInfos=userInfoMapper.selectByNameAndPassword(username, password);
        if(userInfos!=null&&userInfos.size()>0){
            return userInfos.get(0);
        }
        return null;
    }
}
